package com.template.api.controller.config;

import com.template.api.entity.po.ConfigBanner;
import com.template.api.entity.vo.ParamConfigBannerVO;
import com.template.api.service.config.ManConfigBannerService;
import com.template.common.constant.*;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * 后管·Banner配置·Controller
 * @author mltong
 */
@RestController
@RequestMapping(ApiLine.MAN + ApiGroup.CONFIG)
public class ManConfigBannerController {

    @Resource
    private ManConfigBannerService service;

    /**
     * 查询Banner列表
     * @param param 查询参数
     * @return
     */
    @GetMapping(ApiVersion.VERSION_202505 + "/banner")
    public CommonResult<CommonPage<ConfigBanner>> listBanner(ParamConfigBannerVO param){
        return CommonResult.success(service.listBanner(param));
    }

    /**
     * 查询Banner详情
     * @param id 主键ID
     * @return
     */
    @GetMapping(ApiVersion.VERSION_202505 + "/banner/{id}")
    public CommonResult<ConfigBanner> getBanner(@PathVariable("id") Integer id){
        return CommonResult.success(service.getBanner(id));
    }

    /**
     * 新增Banner
     * @param param 新增参数
     * @return
     */
    @PostMapping(ApiVersion.VERSION_202505 + "/banner")
    public CommonResult<Void> addBanner(@RequestBody ConfigBanner param){
        service.addBanner(param);
        return CommonResult.success();
    }

    /**
     * 修改Banner
     * @param param 修改参数
     * @return
     */
    @PutMapping(ApiVersion.VERSION_202505 + "/banner")
    public CommonResult<Void> editBanner(@RequestBody ConfigBanner param){
        service.editBanner(param);
        return CommonResult.success();
    }

    /**
     * 删除Banner
     * @param id 主键ID
     * @return
     */
    @DeleteMapping(ApiVersion.VERSION_202505 + "/banner/{id}")
    public CommonResult<Void> deleteBanner(@PathVariable("id") Integer id){
        service.deleteBanner(id);
        return CommonResult.success();
    }
}
